import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author dreamcatcher
 * @date 2022/3/2 21:58
 * Matcher类
 */
public class RegExp12 {
    public static void main(String[] args) {
        String content = "hello world hello";
        String regex1 = "hello";

        Pattern pattern = Pattern.compile(regex1);
        Matcher matcher = pattern.matcher(content);
//        while (matcher.find()){
//            System.out.println(matcher.start());
//            System.out.println(matcher.end());
//            System.out.println(content.substring(matcher.start(),matcher.end()));
//
//
//        }

        String world = matcher.replaceAll("world");
        System.out.println(world);
    }
}
